import os

from onpolicy.scripts.eval.eval_mpe_my import main
from train import algorithm_name, experiment_name, num_agents, num_landmarks

os.environ["WANDB_API_KEY"] = "0d6d05d9f00ba6c219c73e794931cc157069318d"
env_name = "MPE"
wandb_env_name = "MPE"
scenario_name = "trap_env_move"
# num_landmarks = 1
# num_agents = 4
ele_radius = 0.5
ele_time = 10
random_obs = 0
# algorithm_name = "mat"  # "mappo" "ippo"
# experiment_name = "trans_mlp_relu"
n_rollout_threads = 16
seed = 2
episode_length = 100
num_env_steps = 200000
eval_episodes = 640  # 320

if __name__ == "__main__":
    for trans in [5]:
        for ele_time in [0, 5, 10, 15, 20]:
            model_dir = (
                "E:\\Code_file\\Python\\1211_model_simple\\onpolicy\\scripts\\results\\MPE\\"
                + scenario_name
                + "\\"
                + algorithm_name
                + "\\"
                + experiment_name
                # + "\\run1\\models\\"
                + "\\wandb\\"
                + str(trans)
                + "\\files\\"
            )
            import yaml

            # 打开all_args.model_dir文件夹下的config.yaml文件，读取其中的内容
            config_path = os.path.join(model_dir, "config.yaml")
            with open(config_path, "r") as f:
                config = yaml.safe_load(f)

            # 提取 ele_time 和 ele_radius
            train_ele_time = config.get("ele_time", 0)["value"]  # 默认值为 0
            train_ele_radius = config.get("ele_radius", 0.0)["value"]  # 默认值为 0.0
            argv = [
                # "--use_wandb",
                # "False",
                # "--share_policy",
                "--env_name",
                f"{env_name}",
                "--algorithm_name",
                f"{algorithm_name}",
                "--experiment_name",
                f"{experiment_name}",
                "--scenario_name",
                f"{scenario_name}",
                "--num_agents",
                f"{num_agents}",
                "--num_landmarks",
                f"{num_landmarks}",
                "--n_rollout_threads",
                f"{n_rollout_threads}",
                "--seed",
                f"{seed}",
                "--episode_length",
                f"{episode_length}",
                "--num_env_steps",
                f"{num_env_steps}",
                "--eval_episodes",
                f"{eval_episodes}",
                "--model_dir",
                f"{model_dir}",
                "--ele_time",
                f"{ele_time}",
                "--ele_radius",
                f"{ele_radius}",
                "--train_ele_time",
                f"{train_ele_time}",
                "--train_ele_radius",
                f"{train_ele_radius}",
                "--random_obs",
                f"{random_obs}",
                "--wandb_env_name",
                f"{wandb_env_name}",
                "--n_trans",
                f"{trans}",
            ]
            main(argv)
